//
//  ViewController.m
//  UI_FrameAndBounds
//
//  Created by dllo on 16/6/4.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "ViewController.h"
#define kFrame(VIEW) NSLog(@"view1 frame: x: %lf, y: %lf, w: %lf, h: %lf",VIEW.frame.origin.x,VIEW.frame.origin.y,VIEW.frame.size.width,VIEW.frame.size.height);


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self creatSubViews];
    // Do any additional setup after loading the view, typically from a nib.
}

-(void)creatSubViews{
    //创建视图1,添加到self.view上
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 300, 200)];
    view1.backgroundColor = [UIColor redColor];
    [self.view addSubview:view1];
    [view1 release];
    
    
    //创建视图2,添加到视图1上
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    view2.backgroundColor = [UIColor yellowColor];
    [view1 addSubview:view2];
    [view2 release];
    
    NSLog(@"VIEW frame: x: %lf,y: %lf,w: %lf, h: %lf",view1.bounds.origin.x,view1.bounds.origin.y,view1.bounds.size.width,view1.bounds.size.height);
    
    //改变view1的bounds,改变了它的子视图位置
    view1.bounds =CGRectMake(0, 0, 300, 200);
    
    kFrame(view1);
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
